// 数据分析配置
export const AnalysisConfig = {
  // 分析类型配置
  types: {
    performance: {
      name: '成绩表现分析',
      metrics: ['avgScore', 'passRate', 'distribution', 'accuracy'],
      dimensions: ['subject', 'difficulty', 'questionType'],
      trends: true
    },
    progress: {
      name: '学习进度分析',
      metrics: ['completion', 'timeSpent', 'accuracy'],
      dimensions: ['topic', 'chapter', 'difficulty'],
      trends: true
    },
    comparison: {
      name: '对比分析',
      metrics: ['score', 'accuracy', 'timeSpent'],
      dimensions: ['individual', 'group', 'class'],
      trends: false
    },
    prediction: {
      name: '预测分析',
      metrics: ['expectedScore', 'riskLevel', 'potential'],
      dimensions: ['subject', 'topic'],
      trends: true
    },
    diagnostic: {
      name: '诊断分析',
      metrics: ['weakPoints', 'suggestions', 'patterns'],
      dimensions: ['knowledge', 'skill', 'error'],
      trends: false
    }
  },

  // 分析周期配置
  timeRanges: {
    daily: { days: 1, interval: 'hour' },
    weekly: { days: 7, interval: 'day' },
    monthly: { days: 30, interval: 'day' },
    quarterly: { days: 90, interval: 'week' },
    yearly: { days: 365, interval: 'month' }
  },

  // 数据聚合配置
  aggregations: {
    score: ['avg', 'min', 'max', 'median'],
    accuracy: ['rate', 'count', 'percentage'],
    time: ['total', 'avg', 'distribution']
  },

  // 分布区间配置
  distributions: {
    score: [
      { range: [0, 60], label: '不及格' },
      { range: [60, 70], label: '及格' },
      { range: [70, 80], label: '中等' },
      { range: [80, 90], label: '良好' },
      { range: [90, 100], label: '优秀' }
    ],
    time: [
      { range: [0, 30], label: '很快' },
      { range: [30, 60], label: '正常' },
      { range: [60, 120], label: '偏慢' },
      { range: [120, null], label: '太慢' }
    ]
  },

  // 可视化配置
  visualization: {
    colors: [
      '#1890FF', '#2FC25B', '#FACC14', '#223273',
      '#8543E0', '#13C2C2', '#3436C7', '#F04864'
    ],
    charts: {
      performance: 'line',
      distribution: 'bar',
      proportion: 'pie',
      correlation: 'scatter',
      trend: 'area'
    }
  },

  // 导出配置
  export: {
    formats: ['pdf', 'excel', 'csv', 'html'],
    templates: {
      performance: 'templates/performance.ejs',
      progress: 'templates/progress.ejs',
      diagnostic: 'templates/diagnostic.ejs'
    },
    options: {
      pdf: {
        format: 'A4',
        orientation: 'portrait'
      },
      excel: {
        sheetName: '数据分析报告'
      }
    }
  },

  // 分析算法配置
  algorithms: {
    // 评分预测
    prediction: {
      minDataPoints: 10,          // 最少需要的数据点
      confidenceThreshold: 0.8,   // 置信度阈值
      features: [                 // 预测特征
        'historicalScores',
        'completionRate',
        'accuracyRate',
        'studyTime',
        'questionDifficulty'
      ]
    },
    // 知识点诊断
    diagnosis: {
      minSampleSize: 5,          // 最小样本量
      weakPointThreshold: 0.6,    // 薄弱点判定阈值
      significanceLevel: 0.05     // 显著性水平
    }
  },

  // 性能优化配置
  optimization: {
    // 缓存配置
    cache: {
      ttl: 3600,                 // 缓存时间（秒）
      maxSize: 100,              // 最大缓存条目
      cleanupInterval: 300       // 清理间隔（秒）
    },
    // 批处理配置
    batch: {
      maxSize: 1000,             // 最大批处理大小
      timeout: 30000             // 超时时间（毫秒）
    }
  },

  // 异常检测配置
  anomalyDetection: {
    enabled: true,
    rules: {
      score: {
        threshold: 2,            // 标准差倍数
        minDeviation: 10        // 最小偏差
      },
      time: {
        threshold: 3,
        minDeviation: 300       // 秒
      }
    }
  }
};

// 报表配置
export const ReportConfig = {
  // 报表类型配置
  types: {
    performance: {
      name: '成绩报告',
      sections: ['summary', 'details', 'trends', 'recommendations']
    },
    progress: {
      name: '进度报告',
      sections: ['overview', 'milestones', 'status', 'nextSteps']
    },
    diagnostic: {
      name: '诊断报告',
      sections: ['analysis', 'weakPoints', 'suggestions', 'resources']
    }
  },

  // 导出选项
  export: {
    // PDF 配置
    pdf: {
      format: 'A4',
      orientation: 'portrait',
      margins: {
        top: 20,
        right: 20,
        bottom: 20,
        left: 20
      },
      header: {
        height: '20mm',
        contents: '{{title}} - 第 {{pageNumber}} 页'
      }
    },
    // Excel 配置
    excel: {
      sheetName: '数据报告',
      styles: {
        header: {
          font: { bold: true },
          fill: { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FFE0E0E0' } }
        }
      }
    },
    // 报表模板配置
    templates: {
      performance: 'templates/performance.ejs',
      progress: 'templates/progress.ejs',
      diagnostic: 'templates/diagnostic.ejs'
    }
  }
};
